home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3.iso / include / outstr.c < prev    next >
Text File  |  1995-01-19  |  1KB  |  50 lines

  1. // Fill in borland library.
  2.  
  3. #undef FillMemory
  4. void FillMemory( LPTSTR lpszBuffer, int Bytes, BYTE c )
  5. {
  6.    memset( lpszBuffer, c, Bytes );
  7. }    
  8.  
  9. #undef ZeroMemory
  10. void ZeroMemory( LPTSTR lpszBuffer, int Bytes )
  11. {
  12.    memset( lpszBuffer, 0, Bytes );
  13. }    
  14.  
  15. // Simple utility routine that shows progression.
  16. // This is used in most multithreaded synchronization programs.
  17.  
  18. OutputString(HWND hWnd, LPSTR lpszOperation)
  19. {
  20.    TCHAR szBuffer[512];         // work area for print formatting
  21.    SYSTEMTIME st;               // time here.
  22.  
  23.    static int row = 0;
  24.    static int msg_num = 1;
  25.    HDC hDC = GetDC( hWnd );
  26.  
  27.    GetLocalTime( &st );
  28.    FillMemory( szBuffer, 100, 32 );
  29.    TextOut( hDC, 0, row, szBuffer, 100 );
  30.    //  Message number and tick count are printed with message to help 
  31.    // illustrate the synchronization of activity.
  32. #if defined(OUTSTR_JUST_MESSAGE)
  33.    wsprintf( szBuffer, "%s", lpszOperation );
  34. #elif defined(OUTSTR_SHOW_TIME)
  35.    wsprintf( szBuffer, "At %2d:%2d:%2d:%3d -> %s",
  36.              st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
  37.              lpszOperation );
  38. #else // show message number
  39.    wsprintf( szBuffer, "%3d: %s", msg_num++, lpszOperation );
  40. #endif
  41.  
  42.    TextOut( hDC, 0, row, szBuffer, lstrlen( szBuffer ) );
  43.  
  44.    if ( row > 200 )
  45.        row = 0;
  46.    else 
  47.        row += 20;
  48.    ReleaseDC( hWnd, hDC );
  49. }
  50.